<template>
	<view class="mine-main">
		<view class="head">
			<view class="avatar-area">
				<image class="avatar" :src="userInfo.avatar" mode=""></image>
				<view class="user-info">
					<template v-if="userInfo.username">
						<view>欢迎您:</view>
						<view>{{userInfo.username}}</view>
					</template>
					<template v-else>
						<view>Hi~</view>
						<view>您还没有登陆呢</view>
					</template>
				</view>
			</view>
			<image class="icon-setting" src="../../static/icons/setting.png" @tap="goSetting" mode=""></image>
		</view>
		<div class="btns" v-if="!userInfo.username">
			<navigator url="login/register" class="btn btn-reg">注册</navigator>
			<navigator url="login/login" class="btn btn-login">登陆</navigator>
		</div>
		<!-- 我的订单 -->
		<view class="my-orders">
			<div class="title">
				我的订单
			</div>
			<div class="navs">
				<!-- 订单状态  1 已付款 ;  2 已发货; 3: 已收货;   9 申请退款 -->
				<navigator class="nav-item" url="./order/index?type=0">
					<image class="icon" src="../../static/icons/icon-pay.png"></image>
					<div class="text">待付款</div>
				</navigator>
				<navigator class="nav-item" url="./order/index?type=1">
					<image class="icon" src="../../static/icons/pay-done.png"></image>
					<div class="text">已付款</div>
				</navigator>
				<navigator class="nav-item" url="./order/index?type=2">
					<image class="icon" src="../../static/icons/icon-car.png"></image>
					<div class="text">待收货</div>
				</navigator>
				<navigator class="nav-item" url="./order/index?type=3">
					<image class="icon" src="../../static/icons/icon-done.png"></image>
					<div class="text">已收货</div>
				</navigator>
				<navigator class="nav-item" url="./order/index?type=9">
					<image class="icon" src="../../static/icons/icon-back.png"></image>
					<div class="text">售后</div>
				</navigator>
			</div>
		</view>
		<view class="grid-block">
			<uni-grid :column="3" :show-border="false">
				<uni-grid-item>
					<image src="../../static/icons/save.png" mode=""></image>
					<text class="text">收藏</text>
				</uni-grid-item>
				<uni-grid-item>
					<image src="../../static/icons/brand.png" mode=""></image>
					<text class="text">品牌</text>
				</uni-grid-item>
				<uni-grid-item>
					<image src="../../static/icons/article.png" mode=""></image>
					<text class="text">文章</text>
				</uni-grid-item>
				<uni-grid-item>
					<navigator url="./address/index">
						<image src="../../static/icons/address.png" mode=""></image>
						<text class="text">
							地址
						</text>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<image src="../../static/icons/card.png" mode=""></image>
					<text class="text">卡包</text>
				</uni-grid-item>
				<uni-grid-item>
				    <image src="../../static/icons/kf.png" mode=""></image>
				    <text class="text">
				    	客服
				    </text>
				</uni-grid-item>
				<uni-grid-item>
				    <image src="../../static/icons/security.png" mode=""></image>
				    <text class="text">
				    	安全
				    </text>
				</uni-grid-item>
				<uni-grid-item>
				    <image src="../../static/icons/kf.png" mode=""></image>
				    <text class="text">
				    	客服
				    </text>
				</uni-grid-item>
				<!-- <uni-grid-item>
				    <text class="text">文本</text>
				</uni-grid-item> -->
			</uni-grid>
		</view>
	</view>
</template>

<script>
	import {checkLogin} from '@/utils/common.js';
	import uniGrid from "@/components/uni-grid/uni-grid.vue"
	import uniGridItem from "@/components/uni-grid-item/uni-grid-item.vue"
	export default {
		name: 'Mine',
		components: {uniGrid,uniGridItem},
		data() {
			return {
				user: {
					avatar: ''
				}
			}
		},
		onLoad() {

		},
		onShow() {
			checkLogin(() => {
				console.log("sorry...")
			})
		},
		computed: {
			userInfo() {
				return this.$store.getters.user;
			}
		},
		methods: {
			goSetting() {
				this.$store.commit('user/REMOVE_USER_INFO');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mine-main {
		box-sizing: border-box;
		padding: 0 40rpx;

		.head {
			display: flex;
			justify-content: space-between;
			width: 100%;
			height: 150rpx;
			margin-top: 20rpx;

			.avatar-area {
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.avatar {
					width: 150rpx;
					height: 150rpx;
					border-radius: 50%;
					background-color: #C8C7CC;
				}

				.user-info {
					margin-left: 32rpx;
					font-size: 28rpx;
					color: #3D4C46;
					letter-spacing: 1px;
				}
			}

			.icon-setting {
				width: 50rpx;
				height: 50rpx;
			}
		}

		.btns {
			margin: 40rpx auto;
			display: flex;
			justify-content: center;
			align-items: center;

			.btn {
				width: 182rpx;
				height: 76rpx;
				box-sizing: border-box;
				border: 1px solid #354E44;
				color: #354E44;
				font-size: 30rpx;
				text-align: center;
				line-height: 76rpx;
				border-radius: 10rpx;
				margin: 0 30rpx;

				&.btn-reg:active {
					background-color: #354E44;
				}

				&.btn-login {
					background-color: #354E44;
					color: #fff;
				}
			}
		}

		.my-orders {
			width: 670rpx;
			height: 208rpx;
			background: #FFFFFF;
			box-shadow: 0 8px 12px 0 rgba(122, 98, 75, 0.04);
			margin: 52rpx auto;
			border-radius: 5px;
			border-radius: 5px;

			.title {
				height: 72rpx;
				font-size: 26rpx;
				line-height: 76rpx;
				border-bottom: 1px solid #ddd;
				box-sizing: border-box;
				margin: 0 54rpx;
			}

			.navs {
				width: 588rpx;
				height: 55rpx;
				margin: 20rpx auto;
				display: flex;
				justify-content: space-between;
				align-items: center;
				text-align: center;

				.icon {
					width: 40rpx;
					height: 40rpx;
					margin-top: 20rpx;
					border: 0 solid #000000;
				}

				.text {
					font-size: 26rpx;
					line-height: 37rpx;
					text-align: center;
					color: #3E3E3E;
					letter-spacing: 0.93px;
				}
			}
		}
		.grid-block{
			width: 670rpx;
			margin-top: 40rpx;
			background-color: #fff;
			border-radius: 20rpx;
			text-align: center;
			padding-top: 20rpx;
			.uni-grid-item{
				image{
					display: block;
					width: 50rpx;
					height: 50rpx;
					margin: 30rpx auto;
				}
				text{
					font-size: 13px;
					color: #3E3E3E;
					letter-spacing: 0.93px;
				}
			}
		}
	}
</style>
